package io.renren.modules.mybog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.mybog.dao.MessageDao;
import io.renren.modules.mybog.entity.MessageEntity;
import io.renren.modules.mybog.service.MessageService;
import org.springframework.util.StreamUtils;
import org.springframework.util.StringUtils;


@Service("messageService")
public class MessageServiceImpl extends ServiceImpl<MessageDao, MessageEntity> implements MessageService {
    @Autowired
    private MessageDao messageMapper;

    @Override
    public long counts(Integer id) {
        return messageMapper.counts(id);
    }
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<MessageEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)) {
             wrapper.eq("name",key);
        }
        IPage<MessageEntity> page = this.page(
                new Query<MessageEntity>().getPage(params),
               wrapper
        );
        return new PageUtils(page);
    }

}